package cn.wolfcode.trip.admin.controller;

import cn.wolfcode.trip.base.domain.Information;
import cn.wolfcode.trip.base.query.StrategyQueryObject;
import cn.wolfcode.trip.base.service.IInformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/information")
public class InformationController {

    //注入service对象
    @Autowired
    private IInformationService informationService ;

    @RequestMapping("/list.do")
    public String list(@ModelAttribute("qo") StrategyQueryObject qo, Model model){
        model.addAttribute("pageInfo",informationService.query(qo));
        return "information/list" ;
    }


    /*
    *新增或者修改的操作
    *
    * */

    @RequestMapping("/saveOrUpdate.do")
    @ResponseBody
    public Object saveOrUpdate(Information information){
        informationService.saveOrUpdate(information);
        return "redirect:/information/list.do";
    }

}
